pub fn convert_base(num_str: &str, base_to: u32) -> String {
    // 解析输入字符串，提取数字部分和当前基数
    let parts: Vec<&str> = num_str.split('(').collect();
    let number_part = parts[0];
    let base_from = parts[1].trim_end_matches(')').parse::<u32>().unwrap();

    // 将数字部分从当前基数转换为十进制
    let decimal_number = isize::from_str_radix(number_part, base_from).unwrap();
    println!("Converting {} from base {} to base {}: Decimal is {}", number_part, base_from, base_to, decimal_number);

    // 将十进制数转换为目标基数
    to_base(decimal_number, base_to)
}

fn to_base(mut num: isize, base: u32) -> String {
    if num == 0 {
        return "0".to_string();
    }

    let mut result = String::new();
    while num > 0 {
        let digit = num % base as isize;
        result.push_str(&digit_to_char(digit));
        num /= base as isize;
    }

    let final_result = result.chars().rev().collect::<String>();
    println!("Final result: {}", final_result);
    final_result
}

fn digit_to_char(digit: isize) -> String {
    match digit {
        0..=9 => std::char::from_digit(digit as u32, 10).unwrap().to_string(),
        10..=15 => ((b'a' + (digit - 10) as u8) as char).to_string(), // 使用小写字母
        _ => panic!("Invalid digit: {}", digit),
    }
}